home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0399 / 176 / text0000.txt < prev   
Encoding:
Text File  |  1994-08-27  |  3.1 KB  |  78 lines

  1. Hi!
  2.  
  3. After having been fooling around for a few dozen minutes with something 
  4. sh-ish like
  5.  
  6.     if [ "$blahfoo" = "" ]
  7.  
  8. and wondering why it doesn't work, I just remembered that ARGV doesn't
  9. support empty parameters. ARGGGG-V !
  10.  
  11.                                     *
  12.  
  13. Do you remember the discussion on this subject on Usenet?  As far as I can
  14. recall, this discussion didn't come to a definite end, did it?
  15.  
  16. Several proposals have been made, and the one which seemed to be most 
  17. robust one looked like the following (if I remember correctly):
  18.  
  19.     If the command line does _not_ contain empty arguments,
  20.     the old ARGV standard applies; there are no additions.  This is
  21.     for maximal backwards compatibelity with old (unaware) applications.
  22.  
  23.     _If_ (and only if) there are empty arguments, they're substituted
  24.     by single spaces, and their position in argv[] is signaled thru
  25.     the value of the "ARGV=" environment variable (which was
  26.     reserved by Atari's earlier standard for future usage).  Example:
  27.         foo bar '' '' blah '' frob
  28.     results in the following being appended to the child's environment:
  29.         "ARGV=NULL:2,3,5\0foo\0bar\0 \0 \0blah\0 \0frob\0\0"
  30.                   ^^^^^^^^^^
  31.                (see notes below)
  32.  
  33.     A program which is aware of the new standard will notice the magic
  34.     word "NULL" in ARGV's value and will decode the argv[] indexes it
  35.     signals.
  36.  
  37.     A program which is not aware of the new standard, but which is aware
  38.     of Atari's old ARGV standard will see spaces in place of empty
  39.     arguments.  The spaces have been introduced to guarantee that
  40.     the parameters stay on their positions.
  41.  
  42.     A totally unaware program (not aware of either standard) won't see 
  43.     the ARGV at all; see below...
  44.     
  45. A few notes:
  46.  
  47. The format of the value of the "ARGV=" environment entry hasn't been
  48. discussed to the last extend yet. We could also use some binary magic
  49. instead of "NULL:".  The positions of null arguments could also be
  50. communicated bit-wise ("010010010") or bit-wise and packed (i.e. base 16,
  51. like "A6").  Personally, I like the list form best ("1,3,4").
  52.  
  53. Non-ARGV-aware programs (those which read their command line from their
  54. basepage) should see the parameters in the right place too..  Of course,
  55. a space can't be inserted in place of an empty argument because spaces
  56. separate words in the basepage's command line.  I suggest substituting
  57. empty args with the two characters "''" (two single quotes) in the basepage.
  58.  
  59. Those programs that use the value of ARGV= for other purposes (Mark
  60. Williams C compiled programs) will conform/work as long as they're not
  61. passed empty args.  If someone tries to pass empty args to them from an
  62. aware shell, these programs will lose.  However, these programs would
  63. also lose in this case if the (new) standard wouldn't exist (because
  64. empty arguments are impossible resp. truncate the ARGV parameters in the
  65. environment), so this is not really a problem.  [Ian Lempore had once
  66. pointed this out.  He used to have good arguments in that usenet
  67. discussion.  He's (of course?) not on this list, so I'll "Cc:" this 
  68. article to him.]
  69.  
  70. I'd like to hear your comments here.  A word from someone @ Atari would
  71. be nice, too.
  72.  
  73. Thanks,
  74. Michael
  75. -- 
  76. Internet: hohmuth@freia.inf.tu-dresden.de
  77.  
  78.